package MySQL_im2;

import Warning.ShowUI;

import java.sql.*;

public class getInfo {
    public boolean found = false;
    private String url = "jdbc:mysql:// 172.19.135.251:3306/tcms?useUnicode=true&characterEncoding=utf8&useSSL=false";
    private String password = "bw040914";
    private String name = "root";
    private Connection connection = null;
    private Statement statement;
    public Connection getConnection() {
        return connection;
    }
    public Statement getStatement() {
        return statement;
    }
    public getInfo(){
        try {
            connection = DriverManager.getConnection(url,name,password);
            statement = connection.createStatement();
            System.out.println("成功");
        } catch (SQLException e) {
            System.out.println(e.toString());;
        }
    }
    public void Found(String name,String password,String pd){
        //数据库预编译操作对象获取
        String sql = "SELECT * FROM manger";
        String manger_name = null;
        String manger_pass=null;
        ResultSet rs =null;
        try {
            rs=statement.executeQuery(sql);
            while(rs.next()){
                manger_pass = rs.getString(4);
                manger_name = rs.getString(1);
                if(pd.equals("登录")){
                    if(manger_name.equals(name)&&manger_pass.equals(password)){
                        found = true;
                        return;
                    }
                }
            }
        } catch (SQLException e) {
            System.out.println(e.toString());
        }
    }
}
